$(".view_list").on("click", function () {
    location.href = "../novel/chapterList?novelid=" + novelid;
})
// $(".homepage_list")
$(".homepage_list>li").on("click", function () {
    var id = $(this).attr('data-novel');
    location.href = "../novel/novelInfo?novelid=" + id;
})
//跳转阅读页面
$(".read_cover>ul>li").eq(2).on("click", function () {
    var cid = $(this).attr('data-chapter');
    location.href = "../novel/chapterContent?novelid=" + novelid + "&chapterid=" + cid;
})
//加入书架
$(".read_cover>ul>li").eq(1).on("click", function () {
    $.ajax({
        url: "/novel/novel/addBookCase",
        type: "post",
        dataType: "json",
        data: {novelid: novelid},
        success: function (data) {
            if (data.status == 0) {
                $(".message_Info>p").html('添加成功');
                $(".message_Info").fadeIn(function () {
                    setTimeout(function () {
                        $(".message_Info").fadeOut()
                    }, 200)
                })
                $(".read_cover>ul>li").eq(0).html($(".read_cover>ul>li").eq(0).attr('date_init'))
            } else {
                $(".message_Info>p").html(data.msg);
                $(".message_Info").fadeIn(function () {
                    setTimeout(function () {
                        $(".message_Info").fadeOut()
                    }, 300)
                })
            }
        }
    });
})

//查看更多
$(".homepage_list>h2>span").bind("click", function (e) {
    var e = e || event;
    e.stopPropagation();
    location.href = "../novel/more?type=1"
})

//选择章节布局样式
$(".sectionCont").height(parseInt($(window).height()) - (2.13 + 2.99) / 2 * 46.875 + "px")
//关闭选择章节界面
$(".sectionHead img").on("click", function () {
    $(".chooseSection").css("display", "none")
})
//显示选择章节界面
$(".getmoreSection").on("click", function (e) {
    var e = e || event;
    e.stopPropagation();
    $(".chooseSection").css("display", "block");
})
var goSection = 0;
var goPrice = 0;
$(".sectionCont>li").on("click", function () {
    if ($(this).attr("check") == "false") {
        $(this).attr("check", "true");
        $(this).find("img").attr("src", "/public/img/images/btn-check.png")
        goSection++;
        goPrice += parseInt($(this).attr("price"));
        $(".sectionFoot>p>span>i").eq(0).html(goSection);
        $(".sectionFoot>p>span>i").eq(1).html(goPrice);
    } else {
        $(this).attr("check", "false");
        $(this).find("img").attr("src", "/public/img/images/btn-nocheck.png")
        goSection--;
        goPrice = goPrice - parseInt($(this).attr("price"));
        $(".sectionFoot>p>span>i").eq(0).html(goSection);
        $(".sectionFoot>p>span>i").eq(1).html(goPrice);
    }
})

//全选效果
$(".sectionHead>span").on("click", function () {
    $(".sectionCont>li").attr("check", "true");
    $(".sectionCont>li").find("img").attr("src", "/public/img/images/btn-check.png")
    $(".sectionFoot>p>span>i").eq(0).html($(".sectionCont>li").length)
    goSection = $(".sectionCont>li").length;
    var allPrice = 0;
    for (var i = 0; i < $(".sectionCont>li").length; i++) {
        allPrice += parseInt($(".sectionCont>li").eq(i).attr("price"))
    }
    $(".sectionFoot>p>span>i").eq(1).html(allPrice);
    goPrice=allPrice;
})

//订阅书籍
 $(".read_cover>ul>li").eq(0).on("click",function(){
    // 订阅书籍
    $(".chooseSection").css("display","block");
 })
//充值订阅
//$(".sectionFoot>span").on("click", function () {
//    location.href = "../html/payfor.html"
//})